$OpenBSD: patch-src_network_socket_qnativesocketengine_unix_cpp,v 1.2 2016/02/10 13:26:46 zhuk Exp $
Fix for cases of >1024 open files.
--- src/network/socket/qnativesocketengine_unix.cpp.orig	Sat Jan 30 09:34:38 2016
+++ src/network/socket/qnativesocketengine_unix.cpp	Sat Jan 30 19:19:51 2016
@@ -50,6 +50,7 @@
 #include <time.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <poll.h>
 #ifndef QT_NO_IPV6IFNAME
 #include <net/if.h>
 #endif
@@ -1068,48 +1069,31 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *da
 
 int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) const
 {
-    fd_set fds;
-    FD_ZERO(&fds);
-    FD_SET(socketDescriptor, &fds);
+    struct pollfd pd;
 
-    struct timeval tv;
-    tv.tv_sec = timeout / 1000;
-    tv.tv_usec = (timeout % 1000) * 1000;
-
-    int retval;
-    if (selectForRead)
-        retval = qt_safe_select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
-    else
-        retval = qt_safe_select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
-
-    return retval;
+    memset(&pd, 0, sizeof(struct pollfd));
+    pd.fd = socketDescriptor;
+    pd.events = selectForRead ? POLLIN : POLLOUT;
+    return poll(&pd, 1, timeout); 
 }
 
 int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool checkWrite,
                        bool *selectForRead, bool *selectForWrite) const
 {
-    fd_set fdread;
-    FD_ZERO(&fdread);
-    if (checkRead)
-        FD_SET(socketDescriptor, &fdread);
-
-    fd_set fdwrite;
-    FD_ZERO(&fdwrite);
-    if (checkWrite)
-        FD_SET(socketDescriptor, &fdwrite);
-
-    struct timeval tv;
-    tv.tv_sec = timeout / 1000;
-    tv.tv_usec = (timeout % 1000) * 1000;
-
+    struct pollfd pd;
     int ret;
-    ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv);
 
-    if (ret <= 0)
-        return ret;
-    *selectForRead = FD_ISSET(socketDescriptor, &fdread);
-    *selectForWrite = FD_ISSET(socketDescriptor, &fdwrite);
-
+    memset(&pd, 0, sizeof(struct pollfd));
+    pd.fd = socketDescriptor;
+    if (checkRead)
+        pd.events |= POLLIN;
+    if (checkWrite)
+        pd.events |= POLLOUT;
+    ret = poll(&pd, 1, timeout); 
+    if (ret > 0) {
+        *selectForRead = ((pd.events & POLLIN) == POLLIN);
+        *selectForWrite = ((pd.events & POLLOUT) == POLLOUT);
+    }
     return ret;
 }
 
